<?php
    @header("Content-type:text/html;charset=utf-8");
    @include_once("./connect.php");

    if(!(isset($_POST["user"]))){
        $obj = array();
        $obj["status"] = false;
        $obj["msg"] = "请传入参数";
        $json = json_encode($obj);
        exit($json);
    }

    $user = $_POST["user"];

    $searchAll = "select count(*) as count from `shopcar` where user = '$user'";
    $resultAll = mysqli_query($conn,$searchAll);
    
    $obj = array();
    if($resultAll){
        $item = mysqli_fetch_assoc($resultAll);
        $count = $item["count"]*1;

        $sql ="select * from `shopcar` where user = '$user'";
    
        $result = mysqli_query($conn,$sql);
    
        if($result){
            $list = array();
            while($item1 = mysqli_fetch_assoc($result)){
                array_push($list,$item1);
            }
            $obj["status"] = true;
            $obj["msg"] = "成功";
            $obj["list"] = $list;
            $obj["count"] = $count;
        }else{
            $obj["status"] = false;
            $obj["msg"] = "sql语句有误";
            $obj["sql"] = $sql;
        }
    }

    echo json_encode($obj);


?>